home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample PMSAM / PMSAM Framework / RoboSamSlot / CheckGestalt.cp < prev    next >
Encoding:
Text File  |  1995-07-28  |  5.2 KB  |  205 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CheckGestalt.cp
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Jeff Brickman
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <3>     2/21/95    TMH        metrowerks compatiblity changes
  13.          <2>    10/20/94    TMH        fussed with
  14.          <1>     10/6/94    JHB        first checked in
  15.  
  16.     To Do:
  17. */
  18.  
  19. #ifndef __GESTALTEQU__
  20. #include "GestaltEqu.h"
  21. #endif
  22.  
  23. #ifndef __OCE__
  24. #include "OCE.h"
  25. #endif
  26.  
  27. #ifndef __TOOLUTILS__
  28. #include "ToolUtils.h"
  29. #endif
  30.  
  31. #ifndef __Thread__
  32. #include "TThread.h"
  33. #endif
  34.  
  35. #ifndef __CheckGestalt__
  36. #include "CheckGestalt.h"
  37. #endif
  38.  
  39.  
  40.  
  41.  
  42. // ---------------------------------------------------------
  43. //         C S y s t e m C o n f i g u r a t i o n
  44. // ---------------------------------------------------------
  45.     
  46. //-------------------------------------------------------------------------
  47. CSystemConfiguration::CSystemConfiguration( void )
  48. {
  49.     fPowerTalkAvailable = false;
  50.     fCommToolBoxAvailable = false;
  51.     fThreadsAvailable = false;
  52.     fAppleEventsAvailable = false;
  53.     fGestaltAvailable = false;
  54.     fSystem71orNewer = false;
  55.     
  56.     this->HasGestalt();
  57. }
  58.     
  59.  
  60. //-------------------------------------------------------------------------
  61. long CSystemConfiguration::MyMaskBit( short theBit)
  62. {
  63.     return 1<<theBit;
  64. }
  65.     
  66.     
  67. //-------------------------------------------------------------------------
  68. Boolean    CSystemConfiguration::HasPowerTalk( void )
  69. {    
  70.     long    aResponse = 0;
  71.     long    aResponseMask = 0;
  72.     
  73.     if (fGestaltAvailable) {
  74.     
  75.         aResponseMask = gestaltOCETBPresent + gestaltOCETBAvailable;    // Rather then which bit is the flag these are the bits
  76.         Gestalt(gestaltOCEToolboxAttr, &aResponse);
  77.         fPowerTalkAvailable = (aResponseMask & aResponse) == aResponseMask;
  78.     }
  79.     
  80.     return fPowerTalkAvailable;
  81. }
  82.  
  83.  
  84. //-------------------------------------------------------------------------
  85. Boolean        CSystemConfiguration::HasCommToolbox( void )
  86. {
  87.     long    aResponse = 0;
  88.     long    aResponseMask = 0;
  89.         
  90.     if (fGestaltAvailable) {
  91.     
  92.     
  93.         // Check to see if the file transfer manager is present and if relevent attributes are present
  94.         
  95.         
  96.         aResponseMask = this->MyMaskBit(gestaltFXfrMgrPresent) + 
  97.                         this->MyMaskBit(gestaltFXfrMgrMultiFile) + 
  98.                         this->MyMaskBit(gestaltFXfrMgrErrorString);
  99.         Gestalt(gestaltFXfrMgrAttr, &aResponse);
  100.         fCommToolBoxAvailable = (aResponseMask & aResponse) == aResponseMask;
  101.  
  102.  
  103.         // Check to see if the terminal manager is present and if relevent attributes are present
  104.         
  105.         
  106.         aResponseMask = this->MyMaskBit(gestaltTermMgrPresent) + 
  107.                         this->MyMaskBit(gestaltTermMgrErrorString);
  108.         Gestalt(gestaltTermMgrAttr, &aResponse);
  109.         fCommToolBoxAvailable &= (aResponseMask & aResponse) == aResponseMask;
  110.  
  111.  
  112.         // Check to see if the connection manager is present and if relevent attributes are present
  113.  
  114.  
  115.         aResponseMask = this->MyMaskBit(gestaltConnMgrPresent) + 
  116.                         this->MyMaskBit(gestaltConnMgrCMSearchFix) + 
  117.                         this->MyMaskBit(gestaltConnMgrErrorString); // this is not being returned as there -> + this->MyMaskBit(gestaltConnMgrMultiAsyncIO);
  118.         Gestalt(gestaltCRMAttr, &aResponse);
  119.         fCommToolBoxAvailable &= (aResponseMask & aResponse) == aResponseMask;
  120.  
  121.  
  122.         // Check to see if the communication resource manager is present and if relevent attributes are present
  123.  
  124.  
  125.         aResponseMask = this->MyMaskBit(gestaltCRMPresent) + 
  126.                         this->MyMaskBit(gestaltCRMPersistentFix) + 
  127.                         this->MyMaskBit(gestaltCRMToolRsrcCalls);
  128.         Gestalt(gestaltCRMAttr, &aResponse);
  129.         fCommToolBoxAvailable &= (aResponseMask & aResponse) == aResponseMask;
  130.     }
  131.     
  132.     return fCommToolBoxAvailable;
  133. }
  134.  
  135.  
  136. //-------------------------------------------------------------------------
  137. Boolean    CSystemConfiguration::HasThreadManager( void )
  138. {
  139.     long aResponse = 0;
  140.     long aResponseMask = 0;
  141.         
  142.     if (fGestaltAvailable) {
  143.         aResponseMask = gestaltThreadMgrPresent + 
  144.                         gestaltSpecificMatchSupport + 
  145.                         gestaltThreadsLibraryPresent; // Rather then which bit are the flags these are the bits
  146.         Gestalt(gestaltThreadMgrAttr, &aResponse);
  147.         fThreadsAvailable = (aResponseMask & aResponse) == aResponseMask;
  148.     }
  149.     
  150.     return fThreadsAvailable;
  151.     
  152. }
  153.     
  154.     
  155. //-------------------------------------------------------------------------
  156. Boolean    CSystemConfiguration::HasAppleEvents( void )
  157. {
  158.     long    aResponse = 0;
  159.     long    aResponseMask = 0;
  160.         
  161.     if (fGestaltAvailable) {
  162.     
  163.             aResponseMask = this->MyMaskBit(gestaltAppleEventsPresent);
  164.             Gestalt(gestaltAppleEventsAttr, &aResponse);
  165.             fAppleEventsAvailable = (aResponseMask & aResponse) == aResponseMask;
  166.     }
  167.     
  168.     return fAppleEventsAvailable;
  169. }
  170.     
  171.     
  172. //-------------------------------------------------------------------------
  173. Boolean    CSystemConfiguration::HasGestalt( void )
  174. {
  175.         
  176.     //fGestaltAvailable = TrapAvailable(_Gestalt);
  177.     fGestaltAvailable = true;        // seems ok today.
  178.     return fGestaltAvailable;
  179. }
  180.     
  181.     
  182. //-------------------------------------------------------------------------
  183. Boolean    CSystemConfiguration::HasSys71orBetter( void )
  184. {
  185.     long    aResponse = 0;
  186.     short    aLowword = 0;
  187.     short    ahighbyte = 0;
  188.     short    alowbyte =0;
  189.     
  190.     if (fGestaltAvailable) {
  191.     
  192.         Gestalt(gestaltSystemVersion, &aResponse);
  193.         aLowword = LoWord(aResponse);
  194.         ahighbyte = aLowword & 0xff00;
  195.         alowbyte = aLowword & 0x00ff;
  196.         if ((ahighbyte >= 7) && (alowbyte >= 1))
  197.             fSystem71orNewer = true;
  198.         else
  199.             fSystem71orNewer = false;
  200.             
  201.     }
  202.         
  203.     return fSystem71orNewer;
  204.